
import { ref } from 'vue'
import { listNotice } from '@/api/system/notice'
export default function noticeHook () {
  let formData = ref([
    {
      type: "input",
      label: "公告标题",
      placeholder: "请输入公告标题",
      prop: "title"
    },
    {
      type: "input",
      label: "操作人员",
      prop: "title"
    },
    {
      type: "select",
      label: "类型",
      prop: "title",
      options: [
        {
          label: "通知",
          value: 1
        },
        {
          label: "公告",
          value: 2
        }
      ]
    }
  ])

  // 准备好表头数据
  let columnsData = ref([
    {
      type: "selection"
    }, {
      type: "index",
      label: "序号"
    },
    {
      label: "公告标题",
      prop: "noticeTitle"
    },
    {
      label: "公告类型",
      key: 'noticeType'
    },
    {
      label: "状态",
      key: 'status'
    },
    {
      label: "创建者",
      prop: "createBy"
    },
    {
      label: "创建时间",
      prop: "createTime"
    },
    {
      label: "操作",
      key: "action"
    }
  ])
  let noticeList = ref([])
  let total = ref(0)

  let getList = async (queryData = { pageNum: 1, pageSize: 3 }) => {
    console.log(queryData, "---子传父的数据----")
    let res = await listNotice(queryData)
    noticeList.value = res.rows;
    total.value = res.total;
  }
  return {
    formData,
    columnsData,
    noticeList,
    getList,
    total,
  }
}